using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using YouVisio.Silverlight.TextDiff;

namespace YouVisio.Silverlight.TextDiffTests
{
    [TestClass]
    public class DiffPartsRetriever_Tests : BaseTestClass
    {
        #region LettersRetriever
        [TestMethod]
        public void LettersRetriever_Can_Get_Letter_By_Index()
        {
            const string str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
            IPartsRetriever<string, char> retriever = new LettersRetriever { Source = str };

            for (var i = 0; i < str.Length; i++)
            {
                Assert.AreEqual(retriever.GetByIndex(i), str[i]);
            }
        }
        [TestMethod]
        public void LettersRetriever_Can_Get_Letters_Length()
        {
            const string str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
            IPartsRetriever<string, char> retriever = new LettersRetriever { Source = str };

            Assert.AreEqual(retriever.Length, str.Length);
        }
        #endregion

        #region Int32Retriever
        [TestMethod]
        public void Int32Retriever_Can_Get_Letter_By_Index()
        {
            var src = new int[] { 1, 5, 16, 354, 8, 4, 14 };
            IPartsRetriever<int[], int> retriever = new Int32Retriever { Source = src };

            for (var i = 0; i < src.Length; i++)
            {
                Assert.AreEqual(retriever.GetByIndex(i), src[i]);
            }
        }
        [TestMethod]
        public void Int32Retriever_Can_Get_Integers_Length()
        {
            var src = new int[] { 1, 5, 16, 354, 8, 4, 14 };
            IPartsRetriever<int[], int> retriever = new Int32Retriever { Source = src };
            Assert.AreEqual(retriever.Length, src.Length);
        }
        #endregion

    }
}